package com.qeeyou.apps.android.craftsman.activity.home;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TableLayout;

import com.qeeyou.apps.android.craftsman.R;
import com.qeeyou.apps.android.craftsman.adapter.TabAdpater;

import java.util.ArrayList;
import java.util.List;

public class SchedulingActivity extends AppCompatActivity {

    private ImageView btnBack;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private LinearLayout btnPublish;

    private TabAdpater mTabAdapter;
    public static final String[] tabTitle = new String[] {"星期一", "星期二", "星期三", "星期四",
            "星期五", "星期六", "星期日" };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scheduling);

        setView();

        setEvent();
    }

    private void setView() {
        btnBack = (ImageView) this.findViewById(R.id.btnBack4Scheduling);
        tabLayout = (TabLayout) this.findViewById(R.id.tabLayout4Scheduling);
        viewPager = (ViewPager) this.findViewById(R.id.viewPager4Scheduling);
        btnPublish = (LinearLayout) this.findViewById(R.id.btnPublish4Scheduling);
    }

    private void setEvent() {
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SchedulingActivity.this.finish();
            }
        });
        List<Fragment> fragments = new ArrayList<Fragment>();
        for(int i = 0; i < tabTitle.length; i++) {
            fragments.add(TabLayoutFragment.newInstance(i + 1));
        }
        mTabAdapter = new TabAdpater(getSupportFragmentManager(), fragments);
        viewPager.setAdapter(mTabAdapter);
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
